<template>
  <div>
    <!-- 按钮 -->
    <el-button style="margin:10px" type="primary" icon="el-icon-refresh-right" circle
      @click="getAllUserDynamicListByTimeDesc"></el-button>
    <!--    <el-input placeholder="请输入搜索内容在点击搜索" v-model="searchText" style="width:300px;background-color: #fff;">
      <el-button slot="append" icon="el-icon-search" @click="getAllUserDynamicListByTimeDesc"></el-button>
    </el-input>
    <el-button style="margin:10px" @click="reSetting">重置</el-button> -->
    <!-- 表格
      data 展示数据 —— 数组类型
    -->
    <el-table style="width: 100%;" border :data="list">
      <el-table-column prop="id" label="id" width="80" align="center">
      </el-table-column>
      <el-table-column prop="adUserName" label="代理商" width="100" align="center">
      </el-table-column>
      <el-table-column label="反馈类型" align="center">
        <template slot-scope="{ row, $index }">
          <p v-if="row.questionType == 1">遇到问题</p>
          <p v-if="row.questionType == 2">提出建议</p>
        </template>
      </el-table-column>
      <el-table-column prop="intro" label="描述" align="center">
      </el-table-column>
      <!--    <el-table-column label="图片" align="center">
        <template slot-scope="{ row, $index }">
          <el-image v-for="item in row.picUrl" :key="item" style="width: 40px; height: 40px; margin-right: 5px;"
            :src="item" :preview-src-list="row.picUrl">
          </el-image>
        </template>
      </el-table-column> -->
      <!--      <el-table-column label="图片" align="center">
                <template slot-scope="{ row, $index }">
          <el-image style="width: 40px; height: 40px; margin-right: 5px;" :src="$staticURL+row.picUrl" v-if="row.picUrl">
          </el-image>
                  </template>
      </el-table-column> -->
      <el-table-column label="图片" align="center">
        <template slot-scope="{ row, $index }">
          <el-image v-for="(item,index) in row.picUrl" :key="index"
            style="width: 40px; height: 40px; margin-right: 5px;" :src="$staticURL+item" v-if="item"
            @click="clickevaluatePicture(row)" :preview-src-list="evaluatePictureList">
          </el-image>
        </template>
      </el-table-column>
      <!--      <el-table-column label="视频" align="center">
        <template slot-scope="{ row, $index }">
          <video :src="row.videoUrl" controls="controls" style="width:60px;height:60px;"></video>
        </template>
      </el-table-column> -->
      <!--    <el-table-column prop="createTime" label="上传时间" align="center" width="100">
      </el-table-column> -->
      <el-table-column prop="contactPhone" label="手机" align="center">
      </el-table-column>
      <el-table-column prop="contactEmail" label="邮箱" align="center">
      </el-table-column>
      <el-table-column prop="createTime" label="上传时间" align="center">
      </el-table-column>
      <!--      <el-table-column label="处理结果" align="center" width="100"
        :filters="[{ text: '不处理', value: '-1' },{ text: '未处理', value: '0' }, { text: '已处理', value: '1' }]"
        :filter-method="filterTag" filter-placement="bottom-end">
        <template slot-scope="{ row, $index }">
          <p v-if="row.status == -1">不处理</p>
          <p v-else-if="row.status == 0">未处理</p>
          <p v-else>已处理</p>
        </template>
      </el-table-column> -->
      <!--   <el-table-column label="驳回原因" align="center">
        <template slot-scope="{ row, $index }">
          <p v-if="row.auditStatus == -1">{{ row.auditResult }}</p>
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="{ row, $index }">
          <!-- <el-popconfirm title="是否删除该记录？" icon="el-icon-info" icon-color="red"  )> -->
            <el-tooltip content="删除记录" placement="top" slot="reference">
              <el-button type="danger" @click="getDelete(row.id)" icon="el-icon-delete"></el-button>
            </el-tooltip>
          <!-- </el-popconfirm> -->
          <!--  <el-popconfirm title="处理反馈？" icon="el-icon-info" icon-color="red" @confirm="handleFeedback(row.id,1)">
            <el-tooltip content="处理反馈" placement="top" slot="reference">
              <el-button type="success" icon="el-icon-check"></el-button>
            </el-tooltip>
          </el-popconfirm>
          <el-popconfirm style="margin-left:10px" title="不处理反馈？" icon="el-icon-info" icon-color="red"
            @confirm="handleFeedback(row.id,-1)">
            <el-tooltip content="不处理反馈" placement="top" slot="reference">
              <el-button type="danger" icon="el-icon-close"></el-button>
            </el-tooltip>
          </el-popconfirm> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination style="margin-top:20px;text-align:center" @size-change="handleSizeChange"
      @current-change="handleCurrentChange" :current-page="pageNumber" :page-sizes="[10, 50, 100]" :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
  </div>
</template>

<script>
  export default {
    name: 'FeedbackAudit',
    mounted() {
      //获取列表数据方法
      this.getAllUserDynamicListByTimeDesc()
    },
    data() {
      return {
        //页码
        pageNumber: 1,
        //每页数量
        pageSize: 10,
        //总条数
        total: 0,
        //列表数据
        list: [],
        //搜索
        searchText: '',
        evaluatePictureList: [],
      }
    },
    methods: {
      // 点击评价图片，大图预览多张图片
      clickevaluatePicture(row) {
        var srclist = []
        for (const imgArr of row.picUrl) {
          // 把数据库传来的图片放进数组里
          srclist.push('https://www.yushiai.com.cn/' + imgArr)
        }
        this.evaluatePictureList = srclist // 赋值
        // console.log(this.evaluatePictureList)
      },
      async getAllUserDynamicListByTimeDesc() {
        let res = await this.$API.members.getAdFeedbackList({
          pageNumber: this.pageNumber,
          pageSize: this.pageSize,
          orderBY: '',
        })
        this.total = res.data.sumLine;
        const arr = [];
        for (let i = 0; i < res.data.rows.length; i++) {
          arr.push(res.data.rows[i].picUrl.split(","))
          res.data.rows[i].picUrl = arr[i]
        }
        this.list = res.data.rows;
      },
      reSetting() {
        this.getAllUserDynamicListByTimeDesc();
      },
      async getDelete(adFeedbackId) {
         
        let res = await this.$API.members.deleteAdFeedback({
          adFeedbackId,
        })
       
        this.getAllUserDynamicListByTimeDesc();
      },
      async handleFeedback(id, status) {
        let res = await this.$API.audit.handleFeedback({
          feedbackId: id,
          status,
        })
        this.getAllUserDynamicListByTimeDesc()
      },
      handleSizeChange(val) {
        // console.log(`每页 ${val} 条`);
        this.pageSize = val
        this.getAllUserDynamicListByTimeDesc()
      },
      handleCurrentChange(val) {
        // console.log(`当前页: ${val}`);
        this.pageNumber = val
        this.getAllUserDynamicListByTimeDesc()
      },
      filterTag(value, row) {
        console.log(value, row)
        return row.status == value;
      },
      filterHandler(value, row, column) {
        // const property = column['property'];
        // return row[property] === value;
      }
    }
  }
</script>

<style>

</style>
